<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>无标题文档</title>
    <link th:href="@{/css/style.css}" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" th:src="@{/js/jquery-1.12.4.js}"></script>
    <script src="https://code.highcharts.com.cn/highcharts/highcharts.js"></script>
    <script src="https://code.highcharts.com.cn/highcharts/modules/exporting.js"></script>
    <script src="https://code.highcharts.com.cn/highcharts/modules/drilldown.js"></script>
    <script src="https://img.hcharts.cn/highcharts-plugins/highcharts-zh_CN.js"></script>
</head>

<body>
<div class="place"><span>位置：</span>
    <ul class="placeul">
        <li>数据统计</li>
        <li>出库统计</li>
        <li>基本内容</li>
    </ul>
</div>
<div class="rightinfo">
    <form id="form" th:action="@{/ckWarehouse/findAllFZ}" method="get">
        <input type="hidden" id="pageNum" th:value="${pageNum}" name="pageNum"/>
        <ul class="tools">
            <li> 所属区域：
                <select name="pid">
                    <option value="0">请选择省份</option>
                    <option th:each="p : ${provinceList}" th:selected="${pid==p.id}" th:value="${p.id}"
                            th:text="${p.pName}">北京
                    </option>
                </select>
                <input type="hidden" th:value="${cid}" name="cid"/>
                <select name="address">
                    <option value="0">请选择城市</option>
                </select>
            </li>
            <script>
                $(function () {
                    ajaxCid($("select[name=pid]").val());

                    $("select[name=pid]").change(function () {
                        ajaxCid($(this).val());
                    });
                });

                function ajaxCid(pid) {
                    $.ajax({
                        url: "/erp/market/customer/ajaxCityPid",
                        data: {"pid": pid},
                        dataType: "JSON",
                        success: function (city) {
                            var op = "<option value='0'>请选择城市</option>";
                            $.each(city, function (i, e) {
                                if (e.id == $("input[name=cid]").val()) {
                                    op += "<option value='" + e.id + "' selected>" + e.cname + "</option>";
                                } else {
                                    op += "<option value='" + e.id + "'>" + e.cname + "</option>";
                                }
                            });
                            $("select[name=address]").html("");
                            $("select[name=address]").append(op);

                        }, error: function () {
                            console.log("错误");
                        }
                    });
                }


            </script>
            <li> 仓库名称:
                <input placeholder="请输入名称" name="wname" th:value="${wname}" type="text"/>
            </li>
            <li class="subBut" onclick="tiaoZhuan(1)"><img th:src="@{/images/t06.png}"/>查询</li>
            <li class="subBut" onclick="qingkong()"><img th:src="@{/images/t03.png}"/>重置</li>
            <script>
                function qingkong() {
                    $("input[name=datemin]").val("");
                    $("input[name=datemax]").val("");
                    $("input[name=wname]").val("");
                    $("select[name=pid]>option:eq(0)").prop("selected", true);
                    $("input[name=cid]").val("");
                    ajaxCid($("select[name=pid]").val());
                }
            </script>
            <li class="subBut" onclick="window.location.href='/erp/ckWarehouse/DCCKW'"><img th:src="@{/images/t02.png}"/>导出
            </li>
        </ul>
        <table class="tablelist">
            <thead>
            <tr>
                <th>序号</th>
                <th>仓库名称</th>
                <th>负责人</th>
                <th>所属区域</th>
                <th>出库数量</th>
                <th>金额</th>
                <th>出库明细</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="ckw,i :${pb.list}">
                <td th:text="${(pb.pageNum-1)*pb.pageSize+i.count}">1</td>
                <td th:text="${ckw.warehouse.cName}">南京21号仓库</td>
                <td th:text="${ckw.warehouse.usre.uname}">朱元璋</td>
                <td th:text="${ckw.warehouse.province.pName+' '+ckw.warehouse.city.cName}">江苏南京</td>
                <td th:text="${ckw.totality}">5</td>
                <td th:text="'￥'+${ckw.totalMoney}+'万'">￥9,876,582</td>
                <td>
                    <a th:href="@{'/ckWarehouse/findByFZ?wid='+${ckw.warehouseId}}" class="tablelink">查看详情</a>
                </td>
            </tr>
            </tbody>
        </table>
        <div class="pagin">
            <div class="message">共<i class="blue" th:text="${pb.total}">1256</i>条记录，当前显示第&nbsp;<i class="blue"
                                                                                                  th:text="${pb.pageNum}">2&nbsp;</i>页
            </div>
            <ul class="paginList">
                <li class="paginItem">
                    <a href="javascript:void(0);" th:onclick="tiaoZhuan([[${pb.isFirstPage?1:pb.pageNum-1}]])">
                        <span th:class="${pb.isFirstPage?'pagepre':'pagenxt roate'}"></span>
                    </a>
                </li>

                <li class="paginItem" th:if="${1+4<=pb.pageNum}"><a th:onclick="tiaoZhuan(1)"
                                                                    href="javascript:void(0);">1</a></li>
                <li class="paginItem more" th:if="${1+5<=pb.pageNum}"><a href="javascript:void(0);">...</a></li>
                <li class="paginItem" th:if="${1+3<=pb.pageNum}"><a th:onclick="tiaoZhuan([[${pb.pageNum-3}]])"
                                                                    href="javascript:void(0);"
                                                                    th:text="${pb.pageNum-3}">3</a></li>
                <li class="paginItem" th:if="${1+2<=pb.pageNum}"><a th:onclick="tiaoZhuan([[${pb.pageNum-2}]])"
                                                                    href="javascript:void(0);"
                                                                    th:text="${pb.pageNum-2}">4</a></li>
                <li class="paginItem" th:if="${1+1<=pb.pageNum}"><a th:onclick="tiaoZhuan([[${pb.pageNum-1}]])"
                                                                    href="javascript:void(0);"
                                                                    th:text="${pb.pageNum-1}">1</a></li>

                <li class="paginItem current"><a href="javascript:void(0);" th:text="${pb.pageNum}">2</a></li>

                <li class="paginItem" th:if="${pb.pages-1>=pb.pageNum}"><a th:onclick="tiaoZhuan([[${pb.pageNum+1}]])"
                                                                           href="javascript:void(0);"
                                                                           th:text="${pb.pageNum+1}">3</a></li>
                <li class="paginItem" th:if="${pb.pages-2>=pb.pageNum}"><a th:onclick="tiaoZhuan([[${pb.pageNum+2}]])"
                                                                           href="javascript:void(0);"
                                                                           th:text="${pb.pageNum+2}">4</a></li>
                <li class="paginItem" th:if="${pb.pages-3>=pb.pageNum}"><a th:onclick="tiaoZhuan([[${pb.pageNum+3}]])"
                                                                           href="javascript:void(0);"
                                                                           th:text="${pb.pageNum+3}">5</a></li>
                <li class="paginItem more" th:if="${pb.pages-5>=pb.pageNum}"><a href="javascript:void(0);">...</a></li>
                <li class="paginItem" th:if="${pb.pages-4>=pb.pageNum}"><a th:onclick="tiaoZhuan([[${pb.pages}]])"
                                                                           href="javascript:void(0);"
                                                                           th:text="${pb.pages}">10</a></li>

                <li class="paginItem">
                    <a href="javascript:void(0);" th:onclick="tiaoZhuan([[${pb.isLastPage?pb.pages:pb.pageNum+1}]])">
                        <span th:class="${pb.isLastPage?'pagepre roate ':'pagenxt '}"></span>
                    </a>
                </li>
            </ul>
        </div>
    </form>
    <br/>
    <br/>
    <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
    <script>

        var data1 = [];
        var chart;


        $(function () {
            $.ajax({
                url: "/erp/ckWarehouse/ajaxFindByFZ",
                data: {"pageNum": $("#pageNum").val()},
                dataType: "JSON",
                async:"false",
                success: function (data) {
                    var data2 = [];
                    $.each(data, function (i, e) {
                        console.log(e);
                        var aa = new Array();
                        var wname = "";
                        $.each(e, function (d, g) {
                            aa.push([g.indent + "", g.totalMoney]);
                            wname = g.warehouse.cname;

                        });
                        aa = {name: wname, id: wname, data: aa};
                        data2.push(aa);
                    });
                    chart = Highcharts.chart('container', {
                        chart: {
                            type: 'column'
                        },
                        title: {
                            text: '出库统计'
                        },
                        xAxis: {
                            type: 'category'
                        },
                        yAxis: {
                            title: {
                                text: '总的收入金额(万)'
                            }
                        },
                        legend: {
                            enabled: false
                        },
                        plotOptions: {
                            series: {
                                borderWidth: 0,
                                dataLabels: {
                                    enabled: true,
                                    format: '{point.y:.2f}万'
                                }
                            }
                        },
                        tooltip: {
                            headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
                            pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}万</b><br/>'
                        },
                        series: [{
                            name: '客户姓名',
                            colorByPoint: true,
                        }],
                        drilldown: {
                            series: data2
                        }
                    });


                    $.ajax({
                        url: "/erp/ckWarehouse/ajaxFindAllFZ",
                        data: {
                            "pageNum": $("#pageNum").val(),
                            "wname": $("input[name=wname]").val(),
                            "pid": $("select[name=pid]").val(),
                            "address": $("input[name=cid]").val(),
                        },
                        dataType: "JSON",
                        async:"false",
                        success: function (data) {
                            console.log(data);
                            $.each(data, function (i, e) {
                                var aa = {name: e.warehouse.cname, y: e.totalMoney, drilldown: e.warehouse.cname};
                                data1.push(aa);
                            });
                            chart.series[0].setData(data1);
                        }
                    });
                }
            });


        });
    </script>


    <script>
        function tiaoZhuan(pageNum) {
            $("#pageNum").val(pageNum);
            $("#form").submit();
        }
    </script>
</div>
<script type="text/javascript">
    $('.tablelist tbody tr:odd').addClass('odd');
</script>
</body>
</html>
